// @ 符号在build/webpack.base.conf.js 中配置 表示 'src' 路径
import request from '@/utils/request'

export default {

  // 普通查询列表
  list() {
    return request({
      url: '/admin/edu/teacher/list',
      method: 'get'
    })
  },

  // 分页模糊查询
  pageList(page, limit, searchObj) {
    return request({
      url: `/admin/edu/teacher/list/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },

  // 删除讲师
  removeById(id) {
    return request({
      url: `/admin/edu/teacher/remove/${id}`,
      method: 'delete'
    })
  },

  // 新增讲师
  save(teacher) {
    return request({
      url: '/admin/edu/teacher/save',
      method: 'post',
      data: teacher
    })
  },

  // 根据id查询讲师(编辑时调用)
  getById(id) {
    return request({
      url: `/admin/edu/teacher/get/${id}`,
      method: 'get'
    })
  },

  // 更新讲师信息
  updateById(teacher) {
    return request({
      url: '/admin/edu/teacher/update',
      method: 'put',
      data: teacher
    })
  },

  // 批量删除
  batchRemove(idList) {
    return request({
      url: '/admin/edu/teacher/batch-remove',
      method: 'delete',
      data: idList
    })
  },

  // 搜索框自动查询：方式1
  // selectNameListByKey(key) {
  //   return request({
  //     url: `/admin/edu/teacher/list/name/${key}`,
  //     method: 'get'
  //   })
  // },

  // 搜索框自动查询：方式2
  selectNameListByKey(key) {
    return request({
      url: `/admin/edu/teacher/list/name/`,
      params: {
        key
      },
      method: 'get'
    })
  }
}
